package com.hxy.common.pojo;


import lombok.Data;

/**
 * @description:
 * @program: springbootTest
 * @author: HCY
 * @create: 2022/03/10 17:22
 */
@Data
public class CommonResult<T> {

    private int code;

    private String msg;

    private T data;

    public static <T> CommonResult<T> success(T data,String message) {
        CommonResult<T> result = new CommonResult<>();
        result.code = 200;
        result.data = data;
        result.msg = message;
        return result;
    }

    public static <T> CommonResult<T> success(T data) {
        CommonResult<T> result = new CommonResult<>();
        result.code = 200;
        result.data = data;
        result.msg = "";
        return result;
    }

    public static <T> CommonResult<T> success(String message) {
        CommonResult<T> result = new CommonResult<>();
        result.code = 200;
        result.msg = message;
        return result;
    }

    public static <T> CommonResult<T> error(Integer code, String message) {
        CommonResult<T> result = new CommonResult<>();
        result.code = code;
        result.msg = message;
        return result;
    }
}
